
'use strict';

const Controller = require('egg').Controller;
const utility = require("utility") //密码加密

class UserController extends Controller {
  async userList() {
    const { ctx, service, app } = this;
    let { findObj, pageObj } = ctx.request.body;
    // 模糊查询
    let arr = await service.get.getUser({userName: {$regex: findObj.userName}, role: {$gte: findObj.role}}, pageObj);
    this.ctx.body = arr
  }

  async userDelete () {
    const { ctx, service } = this;
    let { userName, passWord } = ctx.request.body;
    let arr = await service.update.upUser({userName, passWord: await utility.md5(passWord)});
    this.ctx.body = arr;
  }

  async userPost() {
    const { ctx, service } = this;
    let { userName, passWord } = ctx.request.body;
    // let arr = await service.update.upUser({userName, passWord});
    this.ctx.body = 'arr';
  }
}

module.exports = UserController;
